package org.example.Controller;

import org.example.Pojo.Goods;
import org.example.Service.Impl.GoodsServiceImpl;
import org.example.Utils.RequirePermission;
import org.example.Utils.UnionResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/Goods")
public class GoodsController {
    @Autowired
    GoodsServiceImpl goodsServiceImpl;
    @RequestMapping("/getAll")
    public UnionResult getAll(){
        return goodsServiceImpl.getAllGoods();
    }
    @RequirePermission("m:goods")
    @RequestMapping("/addGoods")
    public UnionResult addGoods(Goods goods){
        return goodsServiceImpl.addGoods(goods);
    }
    @RequirePermission("m:goods")
    @RequestMapping("/updateGoods")
    public UnionResult updateGoods(Goods goods){
        return goodsServiceImpl.updateGoods(goods);
    }
    @RequirePermission("m:goods")
    @RequestMapping("/deleteGoods")
    public UnionResult deleteGoods(Goods goods){
        return goodsServiceImpl.deleteGoods(goods);
    }
    @RequestMapping("/QueryGoods")
    public UnionResult QueryGoods(String goodsname){return goodsServiceImpl.QueryGoodsByName(goodsname);}
}
